<?php 
require_once 'source.php';
require_once 'config.php';
require_once 'dao/dao_db.php';
require_once 'dao/dao_sys_manage.php';
require_once 'dao/dao_news.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="wrapper">
	<?php require_once 'header.php';?>
	<div id="layout">
		<div id="leftlay"><?php require_once 'leftnav.php';?></div>
		<div id="rightlay">
		<div class="columntitle">
		<?php 
		if($_SESSION['level']==TEACHER||$_SESSION['level']==ADMINISTRATOR){
			echo LOGINFO;
		}else{
			echo GROUPNEWS;
		}
		?>
		</div>
		<div class="columncontent" style="height:300px">
		<?php 
			if($_SESSION['level']==TEACHER||$_SESSION['level']==ADMINISTRATOR){
		?>
		<?php 
			function get_user_level(){
				switch ($_SESSION['level']){
					case STUDENT:
						$userlevel=STUDENTLEVEL;
						break;
					case TEACHER:
						$userlevel=TEACHERLEVEL;
						break;
					case ADMINISTRATOR:
						$userlevel=ADMINLEVEL;
						break;
				}
				return $userlevel;
			}
		?>
			<table id="loginmsg" border="1" cellpadding="0" cellspacing="0" >
				<tr>
					<td width="50%"><?php echo LOGINID;?></td>
					<td width="50%"><?php echo $_SESSION['userid']?></td>
				</tr>
				<tr>
					<td><?php echo USERLEVEL;?></td>
					<td><?php echo get_user_level();?></td>
				</tr>
				<tr>
					<td><?php echo LOGINTIME;?></td>
					<td>
						<?php 
							$result = get_login_time($_SESSION['userid']);
							mysql_close();
							$row=mysql_fetch_array($result);
							echo $row['LASTLOGIN']; 
						?>
					</td>
				</tr>
			</table>
			<?php 
			}elseif(($_SESSION['level'])==STUDENT){
				$result=get_news_list_s($_SESSION['userid']);
				mysql_close();
				if(mysql_num_rows($result)!=0){	
			?>
				<table class="temptable" width="60%">
					<tr>
						<th><?php echo REPORTTITLE?></th>
						<th><?php echo PUBLICDATE?></th>
					</tr>
				<?php 
				while($row=mysql_fetch_array($result)){
				?> 		
					<tr>
						<td><a href="news.php?nid=<?php echo $row['Id']?>"><?php echo $row['TITLE']?></a></td>
						<td><?php echo $row['NEWSDATE']?></td>
					</tr>	
				<?php
					}
				}else{
					echo NOREPORT;
				}
				?>
				</table>
			<?php 
			}
			?>
		</div>
	</div>
	</div>
	
</div>
</body>
</html>